package com.controllers;

import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.inject.Inject;
import javax.inject.Named;

import com.daos.RoleDao;
import com.model.Action;
import com.model.Role;

@Named
@ManagedBean
public class RoleController {

	private RoleDao roleDao;
	
	public RoleController() {
	}
	
	@Inject
	public RoleController(RoleDao roleDao) {
		this.roleDao = roleDao;
	}

	public void saveRole(Role role) {
		roleDao.save(role);
		
	}

	public List<Role> getRoles() {
		return roleDao.getRoles();
	}

	public Role getRoleByName(String name) {
		return roleDao.getRoleByName(name);
	}

	public List<Action> getActions() {
		return roleDao.getActions();
	}

	public List<Role> getRolesByUserId(int id) {
		return roleDao.getRolesByUserId(id);
	}

	public List<Action> getActionsByRole(int id) {
		return  roleDao.getActionsByRole(id);
	}
}
